﻿using System;
using System.IO;
using UnityEngine;

namespace SEXY
{
	// Token: 0x020002A3 RID: 675
	[Serializable]
	public abstract class CharFileInfoCustom : BlockControlBase
	{
		// Token: 0x0600110E RID: 4366 RVA: 0x0006D238 File Offset: 0x0006B438
		public CharFileInfoCustom(int hknum) : base("カスタム情報", 4)
		{
			this.hairKindNum = hknum;
		}

		// Token: 0x0600110F RID: 4367 RVA: 0x0006D2BC File Offset: 0x0006B4BC
		protected void MemberInitialize()
		{
			if (this.shapeValueFace != null)
			{
				for (int i = 0; i < this.shapeValueFace.Length; i++)
				{
					this.shapeValueFace[i] = 0.5f;
				}
			}
			if (this.shapeValueBody != null)
			{
				for (int j = 0; j < this.shapeValueBody.Length; j++)
				{
					this.shapeValueBody[j] = 0.5f;
				}
			}
			this.headId = 0;
			this.skinColor.SetDiffuseRGB(Color.white);
			this.skinColor.SetSpecularRGB(Color.white);
			this.texFaceId = 0;
			this.texTattoo_fId = 0;
			this.tattoo_fColor.SetDiffuseRGBA(Color.white);
			this.matEyebrowId = 0;
			this.eyebrowColor.SetDiffuseRGBA(Color.white);
			this.eyebrowColor.hsvDiffuse.S = 1f;
			this.matEyeLId = 0;
			this.eyeLColor.SetDiffuseRGBA(Color.white);
			this.eyeLColor.hsvDiffuse.S = 1f;
			this.matEyeRId = 0;
			this.eyeRColor.SetDiffuseRGBA(Color.white);
			this.eyeRColor.hsvDiffuse.S = 1f;
			this.eyeWColor.SetDiffuseRGB(Color.white);
			this.texFaceDetailId = 0;
			this.faceDetailWeight = 0.5f;
			this.texBodyId = 0;
			this.texTattoo_bId = 0;
			this.tattoo_bColor.SetDiffuseRGBA(Color.white);
			this.texBodyDetailId = 0;
			this.bodyDetailWeight = 0f;
			this.voicePitch = 1f;
			this.isConcierge = false;
		}

		// Token: 0x06001110 RID: 4368 RVA: 0x0006D458 File Offset: 0x0006B658
		public override bool LoadBytes(byte[] data, int customVer)
		{
			bool result;
			using (MemoryStream memoryStream = new MemoryStream(data))
			{
				using (BinaryReader binaryReader = new BinaryReader(memoryStream))
				{
					int num = binaryReader.ReadInt32();
					int num2 = binaryReader.ReadInt32();
					for (int i = 0; i < num2; i++)
					{
						this.shapeValueFace[i] = Mathf.Clamp(binaryReader.ReadSingle(), 0f, 1f);
					}
					num2 = binaryReader.ReadInt32();
					for (int j = 0; j < num2; j++)
					{
						this.shapeValueBody[j] = Mathf.Clamp(binaryReader.ReadSingle(), 0f, 1f);
					}
					num2 = binaryReader.ReadInt32();
					for (int k = 0; k < num2; k++)
					{
						this.hairId[k] = binaryReader.ReadInt32();
						this.hairColor[k].Load(binaryReader, num);
						this.hairAcsColor[k].Load(binaryReader, num);
					}
					if (2 <= customVer)
					{
						this.hairType = binaryReader.ReadInt32();
					}
					this.headId = binaryReader.ReadInt32();
					this.skinColor.Load(binaryReader, num);
					this.texFaceId = binaryReader.ReadInt32();
					this.texTattoo_fId = binaryReader.ReadInt32();
					this.tattoo_fColor.Load(binaryReader, num);
					this.matEyebrowId = binaryReader.ReadInt32();
					this.eyebrowColor.Load(binaryReader, num);
					this.matEyeLId = binaryReader.ReadInt32();
					this.eyeLColor.Load(binaryReader, num);
					this.matEyeRId = binaryReader.ReadInt32();
					this.eyeRColor.Load(binaryReader, num);
					this.eyeWColor.Load(binaryReader, num);
					this.texFaceDetailId = binaryReader.ReadInt32();
					this.faceDetailWeight = binaryReader.ReadSingle();
					this.texBodyId = binaryReader.ReadInt32();
					this.texTattoo_bId = binaryReader.ReadInt32();
					this.tattoo_bColor.Load(binaryReader, num);
					this.texBodyDetailId = binaryReader.ReadInt32();
					this.bodyDetailWeight = binaryReader.ReadSingle();
					this.name = binaryReader.ReadString();
					this.personality = binaryReader.ReadInt32();
					if (3 <= customVer)
					{
						this.voicePitch = binaryReader.ReadSingle();
					}
					if (4 <= customVer)
					{
						this.isConcierge = binaryReader.ReadBoolean();
					}
					result = this.LoadSub(binaryReader, customVer, num);
				}
			}
			return result;
		}

		// Token: 0x06001111 RID: 4369
		protected abstract bool LoadSub(BinaryReader br, int customVer, int colorVer);

		// Token: 0x06001112 RID: 4370 RVA: 0x0006D6D8 File Offset: 0x0006B8D8
		public bool ModCheck()
		{
			for (int i = 0; i < this.shapeValueFace.Length; i++)
			{
				if (!CharFileInfoCustom.RangeEqualOn(0f, this.shapeValueFace[i], 1f))
				{
					return true;
				}
			}
			for (int j = 0; j < this.shapeValueBody.Length; j++)
			{
				if (!CharFileInfoCustom.RangeEqualOn(0f, this.shapeValueBody[j], 1f))
				{
					return true;
				}
			}
			return this.ModCheckSub();
		}

		// Token: 0x06001113 RID: 4371
		protected abstract bool ModCheckSub();

		// Token: 0x06001114 RID: 4372 RVA: 0x0006D75C File Offset: 0x0006B95C
		protected static bool RangeEqualOn(float min, float val, float max)
		{
			return val >= min && val <= max;
		}

		// Token: 0x0400128E RID: 4750
		public byte sex;

		// Token: 0x0400128F RID: 4751
		public int customLoadVersion;

		// Token: 0x04001290 RID: 4752
		public readonly int hairKindNum;

		// Token: 0x04001291 RID: 4753
		public float[] shapeValueFace;

		// Token: 0x04001292 RID: 4754
		public float[] shapeValueBody;

		// Token: 0x04001293 RID: 4755
		public int[] hairId;

		// Token: 0x04001294 RID: 4756
		public int hairType;

		// Token: 0x04001295 RID: 4757
		public HSColorSet[] hairColor;

		// Token: 0x04001296 RID: 4758
		public HSColorSet[] hairAcsColor;

		// Token: 0x04001297 RID: 4759
		public int headId;

		// Token: 0x04001298 RID: 4760
		public HSColorSet skinColor = new HSColorSet();

		// Token: 0x04001299 RID: 4761
		public int texFaceId;

		// Token: 0x0400129A RID: 4762
		public int texTattoo_fId;

		// Token: 0x0400129B RID: 4763
		public HSColorSet tattoo_fColor = new HSColorSet();

		// Token: 0x0400129C RID: 4764
		public int matEyebrowId;

		// Token: 0x0400129D RID: 4765
		public HSColorSet eyebrowColor = new HSColorSet();

		// Token: 0x0400129E RID: 4766
		public int matEyeLId;

		// Token: 0x0400129F RID: 4767
		public HSColorSet eyeLColor = new HSColorSet();

		// Token: 0x040012A0 RID: 4768
		public int matEyeRId;

		// Token: 0x040012A1 RID: 4769
		public HSColorSet eyeRColor = new HSColorSet();

		// Token: 0x040012A2 RID: 4770
		public HSColorSet eyeWColor = new HSColorSet();

		// Token: 0x040012A3 RID: 4771
		public int texFaceDetailId;

		// Token: 0x040012A4 RID: 4772
		public float faceDetailWeight;

		// Token: 0x040012A5 RID: 4773
		public int texBodyId;

		// Token: 0x040012A6 RID: 4774
		public int texTattoo_bId;

		// Token: 0x040012A7 RID: 4775
		public HSColorSet tattoo_bColor = new HSColorSet();

		// Token: 0x040012A8 RID: 4776
		public int texBodyDetailId;

		// Token: 0x040012A9 RID: 4777
		public float bodyDetailWeight;

		// Token: 0x040012AA RID: 4778
		public string name = string.Empty;

		// Token: 0x040012AB RID: 4779
		public int personality;

		// Token: 0x040012AC RID: 4780
		public float voicePitch = 1f;

		// Token: 0x040012AD RID: 4781
		public bool isConcierge;
	}
}
